$('#ptm').combogrid({
    panelWidth:700,
    url: URL+'/filter_product/type/cas',
    idField:'id',
    textField:'name',
    mode:'remote',
    fitColumns:true,
    columns:[[
        {field:'id',title:'产品编号',width:40},
        {field:'ename',title:'英文名称',align:'left',width:100},
        {field:'name',title:'名称',align:'left',width:80},
        {field:'cas',title:'CAS',align:'left',width:80}
    ]]
});

$('#supplier').combogrid({
    panelWidth:700,
    url: URL+'/filter_supplier',
    idField:'id',
    textField:'name',
    mode:'remote',
    fitColumns:true,
    columns:[[
        {field:'id',title:'编号',width:40},
        {field:'name',title:'供应商',align:'left',width:500}
    ]]
});

    function removerow(obj){
                    var objnum = jQuery(obj).parent().parent().parent().children().size();

                        jQuery(obj).parent().parent().remove();
                }

    function filter(){ 
        if ($('#q').val() != "") {
            window.open(APP+'/Product/search?form=form1&field=q&keywords='+$('#q').val(),'selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
        }else
            window.open(APP+'/Product/search?form=form1&field=q','selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
    }

    function filterCustomer(){ 
        if ($('#cq').val() != "") {
            window.open(APP+'/Customer/search?form=form1&field=cq&keywords='+$('#cq').val(),'selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
        }else
            window.open(APP+'/Customer/search?form=form1&field=cq','selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
    }

    function filterSupplier(){ 
        if ($('#cq').val() != "") {
            window.open(APP+'/Supplier/search/'+'?form=form1&field=cq&keywords='+$('#cq').val(),'selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
        }else
            window.open(APP+'/Supplier/search?form=form1&field=cq','selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
    }

    function addCustomer(return_url){
            window.open(APP+'/Customer/add?form=form1&return='+return_url,'selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
    }

    //打开询价列表，供选择供应商
    function filterInquiry(id){
            window.open(APP+'/Ask_supplier_detail/search?form=form1&field=cq&product_id='+id,'selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
    }
                
    function showdetail(input_type,trans_type){
        var product_id = $('input[name="'+input_type+'_id"]').attr('value');
        if(product_id > 0){
        jQuery.post(
        URL+'/getProductDetail',
        {   product_id:product_id,
            trans_type:trans_type
        },
        function(data){
            data = data.data;
            if(data.customer_id){
                $('select[name="customer_id"]').empty();
                $('select[name="customer_id"]').append(data.customer);
            }
              
            $('#chosed_product').append(data.product_detail);
        },
        'json'
        );
        }
}

    

